<?php
include("../inc/db_connect.php");
if (isset($_POST['pass']) && (trim($_POST['pass'])!='')){
    $nac_s1 = "SELECT * FROM z WHERE mail = '".$_POST['email']."'";
    $nac_q1 = MySQL_Query ($nac_s1);
    $nac1 = MySQL_Fetch_Array ($nac_q1);
    $nac_s2 = "SELECT * FROM user WHERE mail = '".$_POST['email']."'";
    $nac_q2 = MySQL_Query ($nac_s2);
    $nac2 = MySQL_Fetch_Array ($nac_q2);

    if (isset($nac1['id'])){
        $uloz_u = "UPDATE z SET heslo = '".md5($_POST['pass'])."' WHERE id = '".$nac1['id']."' ";
        $uloz_q = MySQL_Query ($uloz_u);
        $del_i = "DELETE FROM kontrolaprihlasenia WHERE email='".$_POST['email']."'";
        $del_q = MySQL_Query ($del_i);
        echo 1;
    } elseif (isset($nac2['id'])){
        $uloz_u = "UPDATE user SET heslo = '".md5($_POST['pass'])."' WHERE id = '".$nac2['id']."' ";
        $uloz_q = MySQL_Query ($uloz_u);
        $del_i = "DELETE FROM kontrolaprihlasenia WHERE email='".$_POST['email']."'";
        $del_q = MySQL_Query ($del_i);
        echo 1;
    } else {
        $del_i = "DELETE FROM kontrolaprihlasenia WHERE email='".$_POST['email']."'";
        $del_q = MySQL_Query ($del_i);
        echo 2;
    }
} else {
    echo 0;
}
?>
